package com.ticket.service.impl;

import com.ticket.dao.CommentDao;
import com.ticket.entity.Comment;
import com.ticket.service.CommentService;
import com.ticket.util.MybatisUtil;
import com.ticket.util.Page;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author 全谢民
 * @version 8.0
 * @description: TODO
 * @date 2023/10/15 21:19
 */
public class CommentServiceImpl implements CommentService {
    static CommentDao cd ;
    static {
        SqlSession sqlSession = MybatisUtil.getSqlSession();
        cd = sqlSession.getMapper(CommentDao.class);
    }
    @Override
    public Page<Comment> selCommentList(Comment comment, Page<Comment> page) {
        List<Comment> dataList = cd.selCommentList(comment, page);
        int count = cd.selCommentListCount(comment);
        page.setDataList(dataList);
        page.setTotalCount(count);
        return page;
    }

    /*
     * @author 全谢民
     * @description TODO 用户删除个人评论
     * @date 2023/10/16 14:21
     */
    @Override
    public int delComment(int commentId) {
        return cd.delComment(commentId);
    }
}
